import React, { Component } from 'react'
import classnames from 'classnames'
import { compantyRoutes } from '../router'
import queryString from 'query-string'
import { Link, withRouter } from 'react-router-dom'
import styles from './Tab.module.scss'

export default withRouter(class CompanyTab extends Component {
  render() {
    const {location} = this.props;
    const oSearch = queryString.parse(location.search);
    return (
      <div className={styles.tab}>
        <div>
          {compantyRoutes.map((item, i) => {
            return (
              <Link
                className={classnames([{ [styles.span_active]: location.pathname.split('/').slice(0,3).join('/') === item.path }])} key={i}
                to={item.path + '?orgId=' + oSearch.orgId}
              >
                {item.title}
              </Link>
            )
          })}
        </div>
      </div>
    )
  }
})
